package com.nine.pesys.model.service.impl;

import com.nine.pesys.base.BaseSupportImpl;
import com.nine.pesys.model.entity.SportField;
import com.nine.pesys.model.service.SportFieldService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * Created by L先森 on 2014/12/26.
 */
@Service
@Transactional
@SuppressWarnings("all")
public class SportFieldServiceImpl extends BaseSupportImpl<SportField> implements SportFieldService {

    @Override
    public List<SportField> getByCondition(SportField sportField) {
        String sql = "from SportField s where 1=1";
        if (sportField.getId()!=null)
            sql += " and s.id ="+sportField.getId();
        if (sportField.getName()!=null)
            sql += " and s.name = '"+sportField.getName()+"'";
        System.out.println(sql+"=========这是sql语句==========");
        return getSession().createQuery(sql).list();
    }
}
